import { storeToRefs } from 'pinia'
import { useStatementStore } from '@/store'

export default function useReportTitle() {
  const statementStore = useStatementStore()
  const {
    year,
    quarter,
    statementName,
    enterpriseName,
    isAnnual,
  } = storeToRefs(statementStore)

  const title = computed(() => {
    const _year = toValue(year)
    const _quarter = toValue(quarter)
    const _enterpriseName = toValue(enterpriseName) || ''
    const _statementName = toValue(statementName) || ''
    const _isAnnual = toValue(isAnnual)

    // 年度
    if (_isAnnual) {
      return `${_enterpriseName}（${_year}年）${_statementName}`
    }

    if (_enterpriseName) {
      return `${_enterpriseName}（${_year}年第${_quarter}季度）${_statementName}`
    }
    return `${_statementName}（${_year}年第${_quarter}季度）`
  })

  return {
    title,
  }
}
